package com.facecard;

import android.app.Activity;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.*;

public class CardView extends Activity {
	SharedPreferences prefs;

	public static final String PREF_FULLNAME = "PREF_FULLNAME";
	public static final String PREF_EMAIL = "PREF_EMAIL";
	public static final String PREF_HOROSCOPE = "PREF_HOROSCOPE";
	public static final String PREF_HOBBIES = "PREF_HOBBIES";
	public static final String PREF_PHONE = "PREF_PHONE";
	public static final String PREF_PIC = "PREF_PIC";
	public static final String PREF_TEMPLATE = "PREF_TEMPLATE";

	@Override
	public void onCreate(Bundle icicle) {
		int intIndexTemplate = -1;
		String strAvatar = ""; 
		
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		super.onCreate(icicle);
		setContentView(R.layout.cardview);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		
		prefs = getSharedPreferences(Commons.STR_PREFERENCE_NAME, Activity.MODE_PRIVATE);

		ImageView imgTempPlate = (ImageView)findViewById(R.id.imgCardViewTemplate);
		intIndexTemplate = prefs.getInt(PREF_TEMPLATE, -1);
		if(intIndexTemplate>-1)
			imgTempPlate.setImageResource(Commons.INT_TEMPLATES[intIndexTemplate]);
		
		ImageView imgAvatar = (ImageView)findViewById(R.id.imgCardViewAvarta);
		strAvatar = prefs.getString(PREF_PIC, "");
		if(strAvatar != "")
		{
			imgAvatar.setImageURI(Uri.parse(strAvatar));
		}
		
		TextView txtContactInfo = (TextView)findViewById(R.id.txtCardViewInfo);
		txtContactInfo.setText(prefs.getString(PREF_FULLNAME, "") + "\n" + 
				"Email: " + prefs.getString(PREF_EMAIL, "")+"\n" + 
				"Horoscope: " + prefs.getString(PREF_HOROSCOPE, "") + "\n" +
				"Hobbies: " + prefs.getString(PREF_HOBBIES, "") + "\n" +
				"Cell: " + prefs.getString(PREF_PHONE, ""));
	}	
}
